// pages/shouye/shouye.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    cardCur: 0,
    swiperList: [{
      id: 0,
      type: 'image',
      url: 'http://tyzct.cn/uploadfile/20181024095641435.jpg'
    }, {
      id: 1,
        type: 'image',
        url: 'http://y2.ifengimg.com/0594160097da9db8/2015/0209/rdn_54d872bda68ce.jpg',
    }],

    
    address:"",
    location:"",
    CustomBar: app.globalData.CustomBar,
    gridCol:3,
    iconList: [{
      icon: 'shopfill',
      color: 'red',
      badge: 0,
      name: '餐厅',
      amap:'050000'
    }, {
      icon: 'picfill',
      color: 'yellow',
      badge: 0,
      name: '风景',
      amap:'110000'
    }, {
      icon: 'writefill',
      color: 'brown',
      badge: 0,
      name: '科教',
      amap:'140000'
    }, {
      icon: 'servicefill',
      color: 'purple',
      badge: 0,
      name: '生活服务',
      amap:'070000'
    }, {
      icon: 'likefill',
      color: 'blue',
      badge: 0,
      name: '医疗',
      amap:'090000'
    }, {
      icon: 'cartfill',
      color: 'green',
      badge: 0,
      name: '购物',
      amap:'060000'
    }, {
      icon: 'discoverfill',
      color: 'purple',
      badge: 0,
      name: '发现'
    }, {
      icon: 'questionfill',
      color: 'mauve',
      badge: 0,
      name: '帮助'
    }, {
      icon: 'commandfill',
      color: 'purple',
      badge: 0,
      name: '问答'
    }, {
      icon: 'brandfill',
      color: 'mauve',
      badge: 0,
      name: '版权'
    }],
  },

  navgeo:function(e){
    console.log("事件=",e)
    console.log("事件的数据=",e.currentTarget.dataset.title)
    wx.navigateTo({
      url: '/pages/tiao/tiao?name='+e.currentTarget.dataset.title+'&amap='+e.currentTarget.dataset.amap+'&location='+this.data.location,
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    var that = this
    wx.getLocation({
      type: 'wgs84',
      success (res) {
        const latitude = res.latitude
        const longitude = res.longitude
        const speed = res.speed
        const accuracy = res.accuracy
        console.log(res)
        that.setData({
          location: res.longitude+','+res.latitude
        })
        wx.request({
          url: 'https://restapi.amap.com/v3/geocode/regeo?parameters', //仅为示例，并非真实的接口地址
          data: {
            key: 'b0121f143057c2f0c3607e48fe21bac9',
            location: res.longitude+','+res.latitude
          },
          header: {
            'content-type': 'application/json' // 默认值
          },
          success (res) {
            console.log(res.data)
            that.setData({
              address:res.data.regeocode.addressComponent
            })
          }
        })
      }
     })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})